package com.yyi.springcloud.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Controller
@RequestMapping("/page")
// 页面映射
public class PageController {
	@RequestMapping("/SensorIndex")
	public String toSemsorIndex(HttpServletRequest request, Model model, HttpServletResponse response) {
		return "/sxl/sensorIndex";
	}

	// 1.搜索引擎主界面
	@RequestMapping("/SearchInfo")
	public String toSearchInfo(HttpServletRequest request, Model model, HttpServletResponse response) {
		return "/sxl/searchInfo";
	}

	// 2.数据列表页面
	// http://localhost:8080/bxxs/page/DataList?labcode=Haierrefrigerator20151214&testunitno=1&primarykey=2017-11-1611:17:211
	@RequestMapping("/DataList")
	public String toDataList(HttpServletRequest request, Model model, HttpServletResponse response) {
		return "/sxl/dataList";
	}

	// 3.历史数据页面
	@RequestMapping("/HistoryData")
	public String toHistoryData(HttpServletRequest request, Model model, HttpServletResponse response) {
		// return "/sxl/historyData";
		return "/gy/historyData";
	}

	// 4.曲线显示
	// http://localhost:8080/bxxs/page/CurveDisplay?labcode=Haierrefrigerator20151214&testdate=2017-11-2109:10:226
	@RequestMapping("/CurveDisplay")
	public String toCurveDisplay(@RequestParam("labcode") String labcode, @RequestParam("testdate") String testdate) {
		return "sxl/curveDisplay";
	}

	// 页面头部
	@RequestMapping("/CurveDisplayTop")
	public String toCurveDisplayTop(HttpServletRequest request, Model model, HttpServletResponse response) {
		return "sxl/curveDisplay-Top";
	}

	// 页面主体内容
	@RequestMapping("/CurveDisplayContent")
	public String toCurveDisplayContent(HttpServletRequest request, Model model, HttpServletResponse response) {
		return "sxl/curveDisplay-Content";
	}

	// 页面底部
	@RequestMapping("/CurveDisplayBottom")
	public String CurveDisplayBottom(HttpServletRequest request, Model model, HttpServletResponse response) {
		return "sxl/curveDisplay-Bottom";
	}

	@RequestMapping("/CurveDisplayLeft")
	public String toCurveDisplayLeft(HttpServletRequest request, Model model, HttpServletResponse response) {
		return "sxl/curveDisplay-Left";
	}

	@RequestMapping("/CurveDisplayMiddle")
	public String toCurveDisplayMiddle(HttpServletRequest request, Model model, HttpServletResponse response) {
		return "sxl/curveDisplay-Middle";
	}

	@RequestMapping("/CurveDisplayRight")
	public String toCurveDisplayRight(HttpServletRequest request, Model model, HttpServletResponse response) {
		return "sxl/curveDisplay-Right";
	}

	// 5.弹出层
	// 5.数据列表页面--Layer弹出层
	// http://localhost:8080/bxxs/page/DataListLayer?labcode=Haierrefrigerator20151214&testunitno=1&primarykey=2017-11-1611:17:211
	@RequestMapping("/DataListLayer")
	public String toDataList_Layer(HttpServletRequest request, HttpServletResponse response) {
		return "layer/middle_dataListLayer";
	}

	// 5.铭牌信息--Layer弹出层
	// http://localhost:8080/bxxs/page/MetaDataLayer
	@RequestMapping("/MetaDataLayer")
	public String toMetaData_Layer(HttpServletRequest request, HttpServletResponse response) {
		return "layer/middle_metaDataLayer";
	}
	// 5.传感器设置--Layer弹出层
	// http://localhost:8080/bxxs/page/SensorConfigLayer
	@RequestMapping("/SensorConfigLayer")
	public String toSensorConfig_Layer(HttpServletRequest request, HttpServletResponse response) {
		return "layer/middle_sensorConfigLayer";
	}

	// 5.曲线显示范围--Layer弹出层
	// http://localhost:8080/bxxs/page/CurveRangeLayer
	@RequestMapping("/CurveRangeLayer")
	public String CurveRangeLayer(HttpServletRequest request, HttpServletResponse response) {
		return "layer/middle_curveRangeLayer";
	}

	// 6.统计值--Layer弹出层
	// http://localhost:8080/bxxs/page/StatisticsLayer
	@RequestMapping("/StatisticsLayer")
	public String StatisticsLayer(HttpServletRequest request, HttpServletResponse response)
	{

		return "layer/middle_statisticsLayer";
	}

	// 7.打印预览--Layer弹出层
	// http://localhost:8080/bxxs/page/PrintPreviewLayer?labcode=Haierrefrigerator20151214&primarykey=2017-11-1611:17:211&testunitno=1
	@RequestMapping("/PrintPreviewLayer")
	public String PrintPreviewLayer(HttpServletRequest request, HttpServletResponse response,Model model)
	{
        String parentName = request.getParameter("parentName");
        System.out.println("父窗口的名字为"+parentName);
        model.addAttribute("parentName",parentName);
		return "layer/middle_printPreviewLayer";
	}

    // 8.测试layer的父子层传递参数
    // http://localhost:8080/bxxs/page/testLayerChild??parentName=demo
    @RequestMapping("/testLayerChild")
    public String TestLayerChild(HttpServletRequest request, HttpServletResponse response,Model model)
    {
        String parentName = request.getParameter("parentName");
        System.out.println("父窗口的名字为"+parentName);
        model.addAttribute("parentName",parentName);
        return "testLayerChild";
    }

}
